function headaddnode() {
    let num = prompt('请输入你要添加的节点的号数');
    let text = document.querySelectorAll('text');
    let showcircle = document.querySelectorAll('.showcircle');
    let showarrow = document.querySelectorAll('.showarrow');
    let showtext = text[0].cloneNode(true);
    let node = svg.children[2].cloneNode(true);
    let line = svg.children[3].cloneNode(true);
    for (let i = 0; i < showcircle.length; i++) {
        let x = showcircle[i].getAttribute('x');
        let tx = text[i + 1].getAttribute('x');
        showcircle[i].setAttribute('x', parseInt(x) + 3 * r);
        text[i + 1].setAttribute('x', parseInt(tx) + 3 * r);
        if (i != showcircle.length - 1) {
            showarrow[i].setAttribute('x', parseInt(x) + 4 * r);
        }
    }
    showtext.innerHTML = num;
    svg.insertBefore(showtext, svg.children[2]);
    svg.insertBefore(line, svg.children[2]);
    svg.insertBefore(node, svg.children[2]);
}